package shujia.day08;

/*
    统计大串中小串出现的次数
    举例：在字符串” woaijavawozhenaijavawozhendeaijavawozhendehenaijavaxinbuxinwoaijavagun”中java出现了5次

 */
public class StringTest5 {
    public static void main(String[] args) {
        String bigStr = "woaijavawozhenaijavawozhendeaijavawozhendehenaijavaxinbuxinwoaijavagun";
        String smallStr = "java";
        int count = 0;
        int i = 0;

        while ((i = bigStr.indexOf(smallStr)) != -1) { // 4  8
            count++;
            bigStr = bigStr.substring(i + smallStr.length());
        }

        System.out.println("小串共出现了 "+count+" 次");


    }
}
